﻿using Enums;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model.Request;
using Newtonsoft.Json;
using TemplateInterfaceService;

namespace Template_Api.Controllers
{
    /// <summary>
    /// 测试控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]//路由规则
    [ApiExplorerSettings(GroupName = nameof(ApiVersionInfo.v2))]//Swagger版本
    public class TestController : ControllerBase
    {
        private readonly ILogger<LoginController> _logger;//日志服务

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger"></param>
        public TestController(ILogger<LoginController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// xxl-Job测试Post_无参数
        /// </summary>
        [HttpPost]
        public void TestPostXXJobNP()
        {
            _logger.LogInformation($"TestPostXXJobNP调用成功！无参数！");
        }

        /// <summary>
        /// xxl-Job测试Post_JSON参数
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public void TestPostXXJob(BasePageRequest req)
        {
            _logger.LogInformation($"TestPostXXJob调用成功！入参：{JsonConvert.SerializeObject(req)}");
        }

        /// <summary>
        /// xxl-Job测试Get_无参数
        /// </summary>
        [HttpGet]
        public void TestGetXXJobNP()
        {
            _logger.LogInformation($"TestGetXXJob调用成功！无参数！");
        }

        /// <summary>
        /// xxl-Job测试Get_Form表单参数
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        [HttpGet]
        public void TestGetXXJobP(string userName, string passWord)
        {
            _logger.LogInformation($"TestGetXXJob调用成功！入参：userName:{userName},passWord:{passWord}");
        }
    }
}
